//
//  TYBaseViewController.m
//  CaiMi
//
//  Created by 冯贺 on 2017/10/12.
//  Copyright © 2017年 冯贺. All rights reserved.
//

#import "TYBaseViewController.h"

@interface TYBaseViewController ()
@property (nonatomic, assign)BOOL isHiddenNav;
@property (nonatomic, copy)NSString * titl;
@end

@implementation TYBaseViewController

- (void)viewDidLoad{
    [super viewDidLoad];
    
    [self drawView];
    
    self.navigationController.navigationBar.hidden = YES;
}

-(instancetype)initWithTitle:(NSString *)title isHidden:(BOOL)ishidden{
    if (self = [super init]) {
        self.titl = title;
        self.isHiddenNav = ishidden;
    }
    return self;
    
}
//绘制页面
- (void)drawView{
    //导航条
    self.myNavgator = [[TYNavgator alloc]init];
    self.myNavgator.hidden = self.isHiddenNav;
    self.myNavgator.frame = CGRectMake(0, 0, SCREEN_WIDTH, navHeight);
    self.myNavgator.middleTItle = _titl;
    [self.view addSubview:self.myNavgator];
    [self.myNavgator.leftBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    //跟视图
    self.contentView = [[UIView alloc]init];
    self.contentView.backgroundColor = kBackgroudColor;
    [self.view addSubview:self.contentView];
    self.view.backgroundColor = [UIColor whiteColor];
    self.contentView.frame = CGRectMake(0, self.isHiddenNav ? 0 : navHeight, SCREEN_WIDTH, (self.isHiddenNav ? SCREEN_HEIGHT: SCREEN_HEIGHT-navHeight-kLiu));
    
}
-(void)backClick{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
